#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define vec vector<int>
#define y1 y_____hahahaha_____1

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;

int read(){int x = 0,sgn = 1;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;for(;isdigit(ch);ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48); return x * sgn;}

const int N = 23;
const int S = (1 << 23) + 10;
const int inf = 0x3f3f3f3f;

int f[S],g[N][N],h[N][S >> 1],lg[S + 1];
int n,m,k,s[100010];

int main(){
#ifndef ONLINE_JUDGE
	freopen("transfer3.in","r",stdin);
#endif
	n = in,m = in,k = in;
	for(int i = 1;i <= n;i++) s[i] = in;
	for(int i = 2;i <= n;i++) g[s[i-1] - 1][s[i] - 1]++;
	int U = 1 << m; memset(f,0x3f,sizeof f); f[0] = 0;
	for(int x = 2;x <= U;x<<=1) lg[x] = lg[x >> 1] + 1;
	int V = U >> 1;
	for(int i = 0;i < m;i++){
		for(int j = 0;j < m;j++) if(i ^ j) h[i][0] += g[j][i] * k - g[i][j];
		for(int s = 1;s <= V;s++){
			int j = lg[s & -s],lst = s ^ (s & -s);
			j += j >= i; h[i][s] = h[i][lst] - (g[j][i] * k - g[i][j]) + (g[i][j] * k + g[j][i]);
		}
	}
	for(int s = 0;s < U - 1;s++)
		for(int i = 0;i < m;i++)
			if(!(s >> i & 1))
				f[s | 1 << i] =
					min(f[s | 1 << i],f[s] + h[i][(s >> i + 1 << i) | (s ^ (s >> i + 1 << i + 1))] * (__builtin_popcount(s) + 1));
	printf("%d\n",f[U - 1]);	
	return 0;
}
